package com.example.http;

import com.example.cofeed.api.BaseApi;

import org.json.JSONObject;

import java.util.HashMap;
import java.util.Map;

import okhttp3.Callback;
import okhttp3.FormBody;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.RequestBody;

/**
 * copyright：
 *
 * @author：anthui creation date： $.
 * @since: 1.0.0$
 * @describe: $
 */
public class HttpManager {

    public static void getHttpClient(String url, Callback call) {

        Map<String, Object> params = new HashMap<>();
        params.put("sign", BaseApi.getSign(params));
        JSONObject jsonObject = new JSONObject(params);
        RequestBody create = RequestBody.create(MediaType.parse("application/json"), jsonObject.toString());

        //构建请求
        Request request = new Request.Builder()
                //需要 将参数拼接在 地址后面，
                .url(url)
                .post(create)
                .build();
        new OkHttpClient.Builder()
//                .addInterceptor()
                .build().newCall(request).enqueue(call);

    }
}
